<!--
 * @Description: 边框组件4
 * @Autor: HuiSir<273250950@qq.com>
 * @Date: 2020-09-07 18:00:52
 * @LastEditTime: 2021-02-19 10:40:11
-->
<template>
    <div class="border-box-4">
        <svg
            :class="`border-svg-container ${reverse && 'reverse'}`"
            :width="width"
            :height="height"
        >
            <polygon
                :fill="backgroundColor"
                :points="`${
                    width - 15
                }, 22 170, 22 150, 7 40, 7 28, 21 32, 24 16, 42 16, ${
                    height - 32
                } 41, ${height - 7} ${width - 15}, ${height - 7}`"
            />
            <polyline
                class="bb4-line-1"
                :stroke="color[0]"
                :points="`145, ${height - 5} 40, ${height - 5} 10, ${
                    height - 35
                } 10, 40 40, 5 150, 5 170, 20 ${width - 15}, 20`"
            />
            <polyline
                :stroke="color[1]"
                class="bb4-line-2"
                :points="`245, ${height - 1} 36, ${height - 1} 14, ${
                    height - 23
                } 14, ${height - 100}`"
            />
            <polyline
                class="bb4-line-3"
                :stroke="color[0]"
                :points="`7, ${height - 40} 7, ${height - 75}`"
            />
            <polyline
                class="bb4-line-4"
                :stroke="color[0]"
                :points="`28, 24 13, 41 13, 64`"
            />
            <polyline
                class="bb4-line-5"
                :stroke="color[0]"
                :points="`5, 45 5, 140`"
            />
            <polyline
                class="bb4-line-6"
                :stroke="color[1]"
                :points="`14, 75 14, 180`"
            />
            <polyline
                class="bb4-line-7"
                :stroke="color[1]"
                :points="`55, 11 147, 11 167, 26 250, 26`"
            />
            <polyline
                class="bb4-line-8"
                :stroke="color[1]"
                :points="`158, 5 173, 16`"
            />
            <polyline
                class="bb4-line-9"
                :stroke="color[0]"
                :points="`200, 17 ${width - 10}, 17`"
            />
            <polyline
                class="bb4-line-10"
                :stroke="color[1]"
                :points="`385, 17 ${width - 10}, 17`"
            />
        </svg>
        <div class="border-box-content">
            <slot></slot>
        </div>
    </div>
</template>

<script>
export default {
    name: 'BorderBox4',
    props: {
        color: {
            //线条色
            type: Array,
            default: () => ['red', 'rgba(0,0,255,0.8)'],
            validator(val) {
                return val.length >= 2 //限制颜色为双色
            },
        },
        reverse: {
            //翻转
            type: Boolean,
            default: false,
        },
        backgroundColor: {
            //背景色
            type: String,
            default: 'transparent',
        },
        width: Number,
        height: Number,
    },
}
</script>

<style lang="scss" scoped>
.border-box-4 {
    position: relative;
    width: 100%;
    height: 100%;
    .reverse {
        transform: rotate(180deg);
    }
    .border-svg-container {
        position: absolute;
        width: 100%;
        height: 100%;
        top: 0px;
        left: 0px;

        & > polyline {
            fill: none;
        }
    }
    .sw1 {
        stroke-width: 1;
    }
    .sw3 {
        stroke-width: 3px;
        stroke-linecap: round;
    }
    .bb4-line-1,
    .bb4-line-2,
    .bb4-line-3,
    .bb4-line-4,
    .bb4-line-5,
    .bb4-line-6,
    .bb4-line-7,
    .bb4-line-8,
    .bb4-line-9,
    .bb4-line-10 {
        stroke-width: 1;
    }
    .bb4-line-9 {
        stroke-dasharray: 100 250;
    }
    .bb4-line-10 {
        stroke-dasharray: 80 270;
    }
    .border-box-content {
        position: relative;
        width: 100%;
        height: 100%;
    }
}
</style>
